<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>作业9 | Hugo Theme Dream</title>

    



<meta name="author" content="Lindixuan" />
<meta name="description" content="" />



<meta name="generator" content="Hugo 0.63.2" />

<link rel="canonical" href="https://lindixuan.gitee.io/post/%E4%BD%9C%E4%B8%9A9/" />


<meta property="og:title" content="作业9" />
<meta property="og:description" content="" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://lindixuan.gitee.io/post/%E4%BD%9C%E4%B8%9A9/" />
<meta property="article:published_time" content="2020-11-11T20:04:46+08:00" />
<meta property="article:modified_time" content="2020-11-11T20:04:46+08:00" />



<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="作业9"/>
<meta name="twitter:description" content=""/>


<link rel="stylesheet" href="/css/semantic.min.css" />
<link rel="stylesheet" href="/css/OverlayScrollbars.min.css" />
<link rel="stylesheet" href="/css/github-markdown.css" />
<link rel="stylesheet" href="/css/site.css" />


<style>
  a {
    color: seagreen !important;
  }
</style>



<style>
  .inverted a {
     color: darkseagreen !important;
  }
</style>


    


  
    <link rel="stylesheet" data-highlight href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/styles/gruvbox-light.min.css" />
  



  </head>

  
  <body style="background: white;">
  
    
<nav class="ui secondary inverted menu dream-menu">

  <div class="item">
    <i class="large link bullseye icon dream-flip-toggle" title="Flip it!"></i>
  </div>
  <div class="item">
    <i class="large link home icon" title="Home" onclick="window.location.href = 'https:\/\/lindixuan.gitee.io'"></i>
  </div>
  <div class="item">
    <i class="large link icon theme-switch" onclick="themeSwitch()"></i>
  </div>
  
  <div class="item">
    <i class="large link search icon" onclick="toggleSearch()"></i>
  </div>
  
</nav>

    <div class="flip-container">
      <div class="flipper">
        <section class="front">
          <div class="dream-max-width">
            
<div class="ui centered relaxed grid dream-grid">
  <div class="sixteen wide mobile sixteen wide tablet twelve wide computer column markdown-body dream-single">

    <section class="ui top attached segment" id="dream-save-post-as-img">
      <header style="margin-top: 0 !important;">
        <h1 class="ui large header">
          作业9
          <div class="sub header">
            @
            
              Lindixuan
            
            · Wednesday, Nov 11, 2020
            · 1 minute read
            · Update at Nov 11, 2020
          </div>
        </h1>
      </header>

      
        <img class="ui image" style="margin-top: 2rem;" src="" />
      

      <article style="margin-top: 2rem;"><h1 id="1-bubble-sort-the-list-33-56-17-8-95-22make-sure-the-final-result-isfrom-small-to-largewrite-out-the-list-after-the-2nd-pass-10-points">1. Bubble Sort the list: 33, 56, 17, 8, 95, 22。Make sure the final result isfrom small to large.Write out the list after the 2nd pass. (10 points)</h1>
<blockquote>
<p>33 17 8 56 22 95<br>
17 8 33 22 56 95<br>
8 17 22 33 56 95</p>
</blockquote>
<pre><code>    void bubble(int a[])
    {
        for(int i=5;i&gt;0)
        {
            for(int j=0;j&lt;i;i++)
            {
                if(a[j]&gt;a[j+1]) swap(a[j],a[j+1]);
            }
        }
    }
</code></pre><h1 id="2-give-a-sorted-array-as-list606575809095-design-an-algorithm-toinsert-the-value-of-x-into-the-sorted-array-then-test-the-algorithm-withvalue-506799">2. Give a sorted array as list={60,65,75,80,90,95}. Design an algorithm toinsert the value of x into the sorted array. Then test the algorithm withvalue 50,67,99.</h1>
<h2 id="思考为什么选择插入点在list头上中间尾巴上的三个数作为算法测试的数据你能解释吗">思考：为什么选择插入点在list头上、中间、尾巴上的三个数作为算法测试的数据，你能解释吗？</h2>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-c" data-lang="c">    <span style="color:#66d9ef">void</span> <span style="color:#a6e22e">insert</span>(<span style="color:#66d9ef">int</span> a[],<span style="color:#66d9ef">int</span> x)
    {
        <span style="color:#66d9ef">for</span>(<span style="color:#66d9ef">int</span> i<span style="color:#f92672">=</span><span style="color:#ae81ff">0</span>;i<span style="color:#f92672">&lt;</span><span style="color:#66d9ef">sizeof</span>(a);i<span style="color:#f92672">+</span><span style="color:#f92672">+</span>)
        {
            <span style="color:#66d9ef">if</span>(x<span style="color:#f92672">&lt;</span>a[i])
            {
                <span style="color:#66d9ef">for</span>(<span style="color:#66d9ef">int</span> j<span style="color:#f92672">=</span><span style="color:#66d9ef">sizeof</span>(a);j<span style="color:#f92672">&gt;</span>i;j<span style="color:#f92672">-</span><span style="color:#f92672">-</span>)
                {
                    a[j]<span style="color:#f92672">=</span>a[j<span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>];
                }
                a[i]<span style="color:#f92672">=</span>x;
            }
        }
    }
</code></pre></div><blockquote>
<p>对于链表，插入在头上、中间、尾巴对应三种不同情况，在头上插入要考虑头结点，在尾巴插入要考虑尾结点，在中间插入要考虑前后结点链接。</p>
</blockquote>
<h1 id="3-what-is-the-state-of-the-stack-after-the-following-sequence-of-push-andpop-operationspush-anne-push-get-push-your--pop-push-my-push-gun">3. What is the state of the stack after the following sequence of Push andPop operations?Push “anne”; Push “get”; Push “your” ; Pop; Push “my” Push “gun”</h1>
<blockquote>
<p>gun<br>
my<br>
get<br>
anne</p>
</blockquote></article>
    </section>

    <footer class="ui attached segment dream-tags">
      
          <a class="ui label">No Tags</a>
      
      <div
        class="ui label"
        style="float: right; cursor: pointer;"
        onclick="savePostAsImg()">
        <i class="save icon"></i>Save as image
      </div>
    </footer>

    

    
    
    

  </div>
  <div class="sixteen wide mobile sixteen wide tablet four wide computer column">
    <article class="dream-header">
  <section class="ui top attached center aligned segment">
    <div class="ui small circular image">
      
        <img src="/img/sleep.jpg">
      
    </div>

    
    <h1 class="ui medium header">Lindixuan&#39;s blog<div class="sub header" style="margin-top: 0.5rem;">好耶！</div>
    </h1>
    

    <div class="ui horizontal list">
      
      <a class="item" href="/tags">
        <i class="tags icon" title="All Tags"></i>
      </a>
      <a class="item" href="/categories">
        <i class="th list icon" title="All Categories"></i>
      </a>
    </div>
  </section>

  

  

  <section class="ui attached segment header-socials">
    <nav class="ui secondary menu dream-menu dream-socials">
  
  
    <div class="item">
      <a href="mailto:1228210482@qq.com">
        <i class=" mail icon" title="Email"></i>
      </a>
    </div>
  

  

  

  

  

  

  

  
</nav>

  </section>

  <section class="ui bottom attached center aligned segment">
    
      <p>© 2020 - 2021 Hugo Theme Dream</p>
    

    <p>Powered by <a href="https://gohugo.io/" target="_blank">Hugo</a> with theme <a href="https://github.com/g1eny0ung/hugo-theme-dream" target="_blank">Dream</a>.</p>

    
  </section>
</article>

  </div>
</div>

          </div>
        </section>
        <section class="back">
          <div class="dream-max-width">
            <div class="ui centered relaxed grid dream-grid dream-back">
  
  
  

  <section class="sixteen wide mobile eight wide tablet four wide computer column dream-column">
    <article>
      <div class="ui top attached segment">
        <h3 class="ui header">Social Links</h3>
      </div>
      <div class="ui bottom attached segment">
        <nav class="ui secondary menu dream-menu dream-socials">
  
  
    <div class="item">
      <a href="mailto:1228210482@qq.com">
        <i class="large mail icon" title="Email"></i>
      </a>
    </div>
  

  

  

  

  

  

  

  
</nav>

      </div>
    </article>
  </section>

  <section class="sixteen wide mobile eight wide tablet four wide computer column dream-column">
    
  </section>

  
    
  
</div>

          </div>
        </section>
      </div>
    </div>

    <script>
  window.darkNav =  true 
</script>
<script src="/js/jquery.min.js"></script>
<script src="/js/semantic.min.js"></script>
<script src="/js/jquery.overlayScrollbars.min.js"></script>
<script src="/js/header.js"></script>
<script src="/js/main.js"></script>
<script src="/js/theme.js"></script>

    
<script src="/js/html2canvas.min.js"></script>
<script src="/js/post.js"></script>


  <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/highlight.min.js"></script>

  
    
      <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/languages/ocaml.min.js"></script>
     
  

  <script>
  hljs.initHighlightingOnLoad()
  setHighlightTheme()

  function setHighlightTheme() {
    var isDark = localStore.getItem('hugo-theme-dream-is-dark')
    var lightTheme = "gruvbox-light"
    var darkTheme = "gruvbox-dark"
    var theme = isDark ? darkTheme : lightTheme

    $('link[data-highlight]').attr('href', 'https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/styles/' + theme + '.min.css')
    $('pre').css('background', isDark ? '#333' : '')
  }
</script>





    
      <div class="ui inverted segment" id="dream-search">
  <div class="ui search">
    <div class="ui transparent input">
      <input class="prompt" type="text" placeholder="Search" />
    </div>
    <div class="results"></div>
  </div>
</div>
<script>
  $(document).ready(function () {
    $.getJSON('https:\/\/lindixuan.gitee.io/index.json', function (data) {
      $('.ui.search').search({
        source: data,
        searchFields: ['title'],
        showNoResults: true,
      })
    })
  })
</script>
<script src="/js/search.js"></script>

    

    
  </body>
</html>
